package com.cl.pattern.observer.demo2;

import java.util.ArrayList;
import java.util.List;

public class ClientTest {
 
    public static void main(String[] args) {
        //这里需要模拟一个发布者，多个订阅者
 
        //消息订阅者
        ICustomer cus01  = new Customer("body01");
        ICustomer cus02  = new Customer("body02");
        ICustomer cus03  = new Customer("body03");
 
        //消息发布者
        List<ICustomer> observers = new ArrayList<ICustomer>();
        observers.add(cus01);
        observers.add(cus02);
        observers.add(cus03);
 
        Publisher subscribe = new Publisher(observers);
        //更新了消息之后，会自动通知消费者
        subscribe.setInformation("message01 ---这是人性的扭曲还是道德的沦丧");
        System.out.println("cus01 取消关注公众号");
        observers.remove(cus01);
        subscribe.setInformation("message02 ---震惊，一群男女光天化日下尽然干这事......");
    }
 
}